﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Model
{
    [Table("Station")]
    public class Station
    {
        private int _stationId;
        private int _totalProcessId;
        private string _stationName;
        private string _stationVersion;
        private string _stationDescription;
        private int _stationStepNumber;
        private string _stationType;
        private string _area;
        private string _reworkStatus;

        // 工站 ID（主键）
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int StationId
        {
            set { _stationId = value; }
            get { return _stationId; }
        }

        // 总流程 ID（外键，非空）
        [Required]
        public int TotalProcessId
        {
            set { _totalProcessId = value; }
            get { return _totalProcessId; }
        }

        // 工站名称（非空）
        [Required]
        [StringLength(255)]
        public string StationName
        {
            set { _stationName = value; }
            get { return _stationName; }
        }

        // 工站版本（非空，默认 001）
        [Required]
        [StringLength(10)]
        public string StationVersion
        {
            set { _stationVersion = value; }
            get { return _stationVersion; }
        }

        // 工站说明（可空）
        public string StationDescription
        {
            set { _stationDescription = value; }
            get { return _stationDescription; }
        }

        // 工站步骤序号（非空）
        [Required]
        public int StationStepNumber
        {
            set { _stationStepNumber = value; }
            get { return _stationStepNumber; }
        }

        // 工站类型（非空）
        [Required]
        [StringLength(255)]
        public string StationType
        {
            set { _stationType = value; }
            get { return _stationType; }
        }

        // 区域（非空）
        [Required]
        [StringLength(255)]
        public string Area
        {
            set { _area = value; }
            get { return _area; }
        }

        // 返修状态（非空，默认 rework）
        [Required]
        [StringLength(50)]
        public string ReworkStatus
        {
            set { _reworkStatus = value; }
            get { return _reworkStatus; }
        }

        // 构造函数
        public Station()
        {
            StationVersion = "001"; // 默认值
            ReworkStatus = "rework"; // 默认值
        }
    }
}